package com.service;

import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.app.Activity;
import android.preference.Preference;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;

import com.service.utills.DataTransfer;
import com.service.utills.JSONConverter;


public class MainActivity extends Activity implements SharedPreferences.OnSharedPreferenceChangeListener {
    private Button startAnOrder;
    private Button signInBtn;
    private Button createAccountBtn;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFormat(PixelFormat.RGBA_8888);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
        setContentView(R.layout.activity_main);

        //Find views
        startAnOrder = (Button) findViewById(R.id.startAnOrderBtn);
        signInBtn = (Button) findViewById(R.id.signInBtn);
        createAccountBtn = (Button) findViewById(R.id.createAccountBtn);

        //Register to notify MainActivity that startAnOrder button has been clicked.
        startAnOrder.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, StartAnOrderActivity.class);
                MainActivity.this.startActivity(intent);
            }
        });
        signInBtn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, RegistrationActivity.class);
                MainActivity.this.startActivity(intent);
            }
        });


        createAccountBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });

    }

    //Called first time when user clicks on the menu button
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    //Opens Registration activity when user clicks on menu icon.
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.itemPrefs:
                startActivity(new Intent(this, RegistrationActivity.class));
                break;
        }
        return true;
    }

    @Override
    public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String s) {

    }

}





